﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Liminds.Common;
using Liminds.Teste.DTO;
using Liminds.DataEntity.Model.data;


namespace Liminds.Teste.Business
{
    public class TesteBusiness
    {

        #region Implementação dos criterios de busca 

        private Dictionary<CriteriaInfo, object> _pesquisa;

        private Dictionary<CriteriaInfo, object> Pesquisa() {
            return _pesquisa;
        }

        #endregion

        public List<DTOTes> ObterLista(string flagSearch)
        {
            #region Popula Criterio de Pesquisa

            _pesquisa = new Dictionary<CriteriaInfo, object>();
            _pesquisa.Add(new CriteriaInfo() {
                                  EntityData = new Entidade01(), 
                                  LikePattern = Common.LikePattern.Both,
                                  LogicalType = LogicalOperator.AND,
                                  NameProperty = "codigo",
                                  SearchType   = LogicalComparator.EQUAL
            }, flagSearch);
                             

            #endregion

            var dataColl = new ColecaoEntidade01().Where(Pesquisa);
            var lista = new List<DTOTes>();
            dataColl.ForEach(data =>
                            {
                                var dto = new DTOTes();
                                dto.Fill(data);
                                lista.Add(dto);
                            });
            return lista;
        }

    }
}
